From d9dedc36ec04bc5053f5a88057bf41aab3bf587b Mon Sep 17 00:00:00 2001 From: Richard Hult Date: Sat, 5 May 2007 10:19:39 +0000 Subject: [PATCH] Fix bugs #428733 and #433301. Turns out the lockFocus logic was flawed, 007-05-05 Richard Hult * gdk/quartz/gdkdrawable-quartz.c: (gdk_quartz_drawable_get_context), (gdk_quartz_drawable_release_context): Fix bugs #428733 and #433301. Turns out the lockFocus logic was flawed, now we only lock/unlock when called outside a real expose event and never flush manually. svn path=/trunk/; revision=17798 --- ChangeLog | 8 ++++++++ gdk/quartz/gdkdrawable-quartz.c | 32 +++++++++++++++----------------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 22b57dccd7..412b7b5e78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-05-05 Richard Hult + + * gdk/quartz/gdkdrawable-quartz.c: + (gdk_quartz_drawable_get_context), + (gdk_quartz_drawable_release_context): Fix bugs #428733 and #433301. + Turns out the lockFocus logic was flawed, now we only lock/unlock + when called outside a real expose event and never flush manually. + 2007-05-03 Behdad Esfahbod * gtk/gtklabel.c (gtk_label_ensure_layout): diff --git a/gdk/quartz/gdkdrawable-quartz.c b/gdk/quartz/gdkdrawable-quartz.c index 3b60a9ce09..113bee4d67 100644 --- a/gdk/quartz/gdkdrawable-quartz.c +++ b/gdk/quartz/gdkdrawable-quartz.c @@ -600,22 +600,23 @@ gdk_quartz_drawable_get_context (GdkDrawable *drawable, gboolean antialias) { GdkDrawableImplQuartz *drawable_impl = GDK_DRAWABLE_IMPL_QUARTZ (drawable); + CGContextRef cg_context; if (GDK_IS_WINDOW_IMPL_QUARTZ (drawable) && GDK_WINDOW_DESTROYED (drawable_impl->wrapper)) return NULL; - CGContextRef cg_context; - if (GDK_IS_WINDOW_IMPL_QUARTZ (drawable)) { GdkWindowImplQuartz *window_impl = GDK_WINDOW_IMPL_QUARTZ (drawable); - - /* Lock focus when not called as part of begin/end paint cycle. - * This is needed to allow broken apps that draw outside of expose - * to still work (somewhat). + + /* Lock focus when not called as part of a drawRect call. This + * is needed when called from outside "real" expose events, for + * example for synthesized expose events when realizing windows + * and for widgets that send fake expose events like the arrow + * buttons in spinbuttons. */ - if (window_impl->begin_paint_count == 0) + if (window_impl->in_paint_rect_count == 0) { window_impl->pool = [[NSAutoreleasePool alloc] init]; if (![window_impl->view lockFocusIfCanDraw]) @@ -695,19 +696,16 @@ gdk_quartz_drawable_release_context (GdkDrawable *drawable, CGContextRestoreGState (cg_context); CGContextSetAllowsAntialiasing (cg_context, TRUE); - /* Only flush and unlock if called outside the expose, since it's - * already handled for otherwise. - */ - if (window_impl->in_paint_rect_count == 0 && window_impl->begin_paint_count == 0) + /* See comment in gdk_quartz_drawable_get_context(). */ + if (window_impl->in_paint_rect_count == 0) { - CGContextFlush (cg_context); [window_impl->view unlockFocus]; - } - if (window_impl->pool) - { - [window_impl->pool release]; - window_impl->pool = NULL; + if (window_impl->pool) + { + [window_impl->pool release]; + window_impl->pool = NULL; + } } } else if (GDK_IS_PIXMAP_IMPL_QUARTZ (drawable)) -- 2.30.2